import Vue from 'vue'
import Router from 'vue-router'

Vue.use(Router)

/* Layout */
import Layout from '../views/layout/Layout'

/**
 * hidden: true                   if `hidden:true` will not show in the sidebar(default is false)
 * alwaysShow: true               if set true, will always show the root menu, whatever its child routes length
 *                                if not set alwaysShow, only more than one route under the children
 *                                it will becomes nested mode, otherwise not show the root menu
 * redirect: noredirect           if `redirect:noredirect` will no redirct in the breadcrumb
 * name:'router-name'             the name is used by <keep-alive> (must set!!!)
 * meta : {
    title: 'title'                the name show in submenu and breadcrumb (recommend set)
    icon: 'icon-name'             the icon show in the sidebar,
    keepAlive: true               if set true, the component will be cache
  }
 **/
export const constantRouterMap = [
  {path: '/login', component: () => import('@/views/login/index'), hidden: true},
  {
    path: '',
    component: Layout,
    redirect: '/home',
    children: [{
      path: 'home',
      name: 'home',
      component: () => import('@/views/home/index'),
      meta: {title: '首页', icon: 'el-icon-s-home', keepAlive: false}
    }]
  },
  {
    path: '',
    component: Layout,
    redirect: '/list',
    children: [{
      path: 'list',
      name: 'list',
      component: () => import('@/views/clubList/index'),
      meta: {title: '审核列表', icon: 'el-icon-s-check', keepAlive: false}
    }]
  },
  {
    path: '',
    component: Layout,
    redirect: '/records',
    children: [{
      path: 'records',
      name: 'records',
      component: () => import('@/views/records/index'),
      meta: {title: '推广记录', icon: 'el-icon-s-unfold', keepAlive: false}
    }]
  },
  {
    path: '',
    component: Layout,
    redirect: '/accounts',
    children: [{
      path: 'accounts',
      name: 'accounts',
      component: () => import('@/views/accounts/index'),
      meta: {title: '账目管理', icon: 'el-icon-coin', keepAlive: false}
    }]
  },
  {
    path: '',
    component: Layout,
    redirect: '/orders',
    children: [{
      path: 'orders',
      name: 'orders',
      component: () => import('@/views/orders/index'),
      meta: {title: '订单管理', icon: 'el-icon-s-order', keepAlive: true, isBack: false}
    }, {
        path: 'orderDetail',
        name: 'orderDetail',
        component: () => import('@/views/orders/orderDetail'),
        meta: {title: '订单详情', keepAlive: false},
        hidden:true
      },
    ]
  },
  {path: '/404', component: () => import('@/views/404'), hidden: true},
  {path: '*', redirect: '/404', hidden: true}
]

export default new Router({
  mode: 'hash', //后端支持可开
  base: '/h5/admin/',
  scrollBehavior: () => ({y: 0}),
  routes: constantRouterMap
})

